package com.atguigu.edu.publisher.mapper;

import com.atguigu.edu.publisher.beans.SubjectOrderAmount;
import com.atguigu.edu.publisher.beans.SubjectOrderCt;
import com.atguigu.edu.publisher.beans.SubjectUserCt;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface SubjectStatsMapper {

    @Select("select \n" +
            "subject_name,\n" +
            "sum(final_amount_cnt) final_amount_sum\n" +
            "from dws_course_order_window\n" +
            "where toYYYYMMDD(stt)=#{date}\n" +
            "group by subject_id,subject_name;")
    List<SubjectOrderAmount> selectOrderAmount(@Param("date") Integer date);

    @Select("select \n" +
            "subject_name,\n" +
            "sum(order_cnt) order_cnt\n" +
            "from dws_course_order_window\n" +
            "where toYYYYMMDD(stt)=#{date}\n" +
            "group by subject_id,subject_name;")
    List<SubjectOrderCt> selectOrderCt(@Param("date") Integer date);

    @Select("select \n" +
            "subject_name,\n" +
            "sum(user_cnt) user_cnt\n" +
            "from dws_course_order_window\n" +
            "where toYYYYMMDD(stt)=#{date}\n" +
            "group by subject_id,subject_name;")
    List<SubjectUserCt> selectUserCt(@Param("date") Integer date);
}
